package com.beiyou.controller;

import java.util.*;

import com.beiyou.dto.UserInfo;
import com.beiyou.local.UserInfoLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.beiyou.service.PurchaseMasterService;
import com.beiyou.dto.PurchaseMasterDto;
import com.beiyou.dto.PurchaseMasterQueryDto;
/**
 * 
 *
 * @author wzby
 * @date 2022-11-01 15:05:44
 */
@RestController
@RequestMapping("/api/purchaseMaster")

public class PurchaseMasterController {

    @Autowired
    private PurchaseMasterService purchaseMasterService;

    @GetMapping
    public List<PurchaseMasterDto> select(PurchaseMasterQueryDto dto){
        return purchaseMasterService.select(dto);
    }

    @PostMapping
    public Integer insert(@RequestBody PurchaseMasterDto purchaseMasterDto){
        UserInfo userInfo = UserInfoLocal.get();
        purchaseMasterDto.setLastUpdateBy(userInfo.getNickName());
        return purchaseMasterService.insert(purchaseMasterDto);
    }

    @PutMapping
    public Integer update(@RequestBody PurchaseMasterDto dto){
        return  purchaseMasterService.update(dto);
    }

    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable  Integer id){
        return purchaseMasterService.delete(id);
    }
}
